package com.huawei.appgallery.apkmanagement.impl.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.widget.button.FitWidthButton;
import huawei.widget.HwTextView;
import java.util.List;
import o.azb;
import o.bbl.b;
import o.bbl.c;
import o.bbl.e;
import o.bbo;
import o.bbq;
import o.cdy;
import o.epv;

public class ApkListAdapter extends BaseAdapter {
    private List<bbq> apkDetailList;
    private final OnClickListener mClickListener;
    private final Context mContext;

    static class a {
        private ImageView ʼ;
        private FitWidthButton ʽ;
        private TextView ˊ;
        private ImageView ˋ;
        private TextView ˎ;
        private HwTextView ˏ;
        private TextView ॱ;
        private View ᐝ;

        public ImageView ˎ() {
            return this.ˋ;
        }

        public void ˏ(ImageView imageView) {
            this.ˋ = imageView;
        }

        public TextView ˊ() {
            return this.ˊ;
        }

        public void ˋ(TextView textView) {
            this.ˊ = textView;
        }

        public HwTextView ˏ() {
            return this.ˏ;
        }

        public void ॱ(HwTextView hwTextView) {
            this.ˏ = hwTextView;
        }

        public FitWidthButton ॱ() {
            return this.ʽ;
        }

        public void ˏ(FitWidthButton fitWidthButton) {
            this.ʽ = fitWidthButton;
        }

        public ImageView ˋ() {
            return this.ʼ;
        }

        public void ॱ(ImageView imageView) {
            this.ʼ = imageView;
        }

        public View ʼ() {
            return this.ᐝ;
        }

        public void ॱ(View view) {
            this.ᐝ = view;
        }

        public void ˏ(TextView textView) {
            this.ॱ = textView;
        }

        public TextView ʻ() {
            return this.ˎ;
        }

        public void ॱ(TextView textView) {
            this.ˎ = textView;
        }
    }

    public ApkListAdapter(List<bbq> list, Context context, OnClickListener onClickListener) {
        this.apkDetailList = list;
        this.mContext = context;
        this.mClickListener = onClickListener;
    }

    public void setData(List<bbq> list) {
        this.apkDetailList = list;
        notifyDataSetChanged();
    }

    public int getCount() {
        if (this.apkDetailList == null || this.apkDetailList.isEmpty()) {
            return 0;
        }
        return this.apkDetailList.size();
    }

    public Object getItem(int i) {
        if (this.apkDetailList == null || this.apkDetailList.isEmpty() || i >= this.apkDetailList.size()) {
            return null;
        }
        return this.apkDetailList.get(i);
    }

    public long getItemId(int i) {
        return (long) i;
    }

    public View getView(int i, View view, ViewGroup viewGroup) {
        bbq o_bbq = (bbq) getItem(i);
        if (o_bbq == null) {
            return new View(this.mContext);
        }
        a aVar;
        if (view == null || !(view.getTag() instanceof a)) {
            a aVar2 = new a();
            view = LayoutInflater.from(this.mContext).inflate(e.ˎ, null);
            azb.ˏ(view);
            aVar2.ˏ((ImageView) view.findViewById(b.ᐝॱ));
            aVar2.ॱ((ImageView) view.findViewById(b.ʻ));
            aVar2.ˋ((TextView) view.findViewById(b.ॱᐝ));
            aVar2.ॱ((HwTextView) view.findViewById(b.ॱˎ));
            aVar2.ˏ((TextView) view.findViewById(b.ˋॱ));
            aVar2.ॱ((TextView) view.findViewById(b.ॱˋ));
            aVar2.ˏ((FitWidthButton) view.findViewById(b.ˏॱ));
            aVar2.ॱ(view.findViewById(b.ˋ));
            azb.ʼ(aVar2.ʼ(), epv.ᐝ());
            view.setTag(aVar2);
            aVar = aVar2;
        } else {
            aVar = (a) view.getTag();
        }
        if (getCount() - 1 == i) {
            aVar.ʼ().setVisibility(8);
        } else {
            aVar.ʼ().setVisibility(0);
        }
        aVar.ॱ().setOnClickListener(this.mClickListener);
        aVar.ॱ().ॱ();
        aVar.ॱ().setTag(o_bbq);
        aVar.ˊ().setText(o_bbq.ˏ());
        aVar.ˏ().setText(o_bbq.ॱ());
        if (TextUtils.isEmpty(o_bbq.ˊ())) {
            aVar.ʻ().setVisibility(8);
        } else {
            aVar.ʻ().setVisibility(0);
            aVar.ʻ().setText(o_bbq.ˊ());
        }
        cdy.ˎ(o.bbl.a.ˏ);
        if (o_bbq.ॱॱ()) {
            cdy.ˏ(o_bbq.ˎ(), aVar.ˎ());
            aVar.ˋ().setVisibility(8);
            aVar.ˏ().setSingleLine(true);
            return view;
        }
        aVar.ˎ().setImageDrawable(bbo.ˎ().getResources().getDrawable(o.bbl.a.ˊ));
        aVar.ˋ().setVisibility(0);
        aVar.ˏ().setSingleLine(false);
        aVar.ˏ().setMaxLines(2);
        aVar.ˏ().setAutoTextInfo(this.mContext.getResources().getDimensionPixelSize(c.ˎ), this.mContext.getResources().getDimensionPixelSize(c.ˊ), 0);
        return view;
    }
}
